
class HlszProxy extends ResourceProxyBase {
    public static NAME: string = "HlszProxy";//必须和excel导出文件一致
    public static Proxy: HlszProxy = null;
    public constructor() {
        super(HlszProxy.NAME);
    }
    public static getProxy() {
        if (!HlszProxy.Proxy) {
            HlszProxy.Proxy = new HlszProxy();
        }
        return HlszProxy.Proxy;
    }

    //登录成功
    public login(data: Object) {
        HlszVO.VO = null;
        HlszVO.getVo().lUserScore = GameVO.getVo().lUserScore;
        game.AppFacade.instance.sendNotification(PanelNotify.HLSZ.OPEN_PLAY_GAME);
    }
    //获取房1配置信息，获取完成后发送匹配玩家请求
    public getRoomInfo(data: Object) {
        HlszVO.getVo().dwServerRule = data["dwServerRule"];
        HlszVO.getVo().wChairCount = data["wChairCount"];
        HlszVO.getVo().wServerType = data["wServerType"];
        HlszVO.getVo().wTableCount = data["wTableCount"];
    }
    //用户进入广场 携带用户所有数据 3-100
    public userJoinSquare(data: Object) {
        let user = data["tagMobileUserInfoHead"];
        HlszVO.getVo().userInfo[user.dwUserID] = user;//广场所有人存入集合
        this.userJoinRoom();
    }
    //用户战绩信息刷新 包括金币 3-101
    public getUserInfo(data: Object) {
        let UserScore = data["UserScore"];
        let dwUserID = data["dwUserID"];
        let lScore = UserScore["lScore"];
        let user = HlszVO.getVo().userInfo[dwUserID];
        if (user) {
            user.lScore = lScore;
        }
        this.userJoinRoom();
    }
    //用户状态变更 入座，离开 3-102
    public userStateModify(data: Object) {
        //用户状态发生改变从缓存的所有用户中找到该用户改变其座位
        let dwUserID = data["dwUserID"];
        let wTableID = data["tableId"];
        let wChairID = data["wChairID"];
        let cbUserStatus = data["cbUserStatus"];
        let user = HlszVO.getVo().userInfo[dwUserID]
        if (user) {
            user.wTableID = wTableID;
            user.wChairID = wChairID;
            user.cbUserStatus = cbUserStatus;
        }
        //当我进入新桌子 重置换桌点击状态
        if (dwUserID == GameVO.getVo().dwUserID && user.wTableID != 65535) {
            HlszVO.getVo().huanzhuoClick = false
        }
        this.userJoinRoom();
    }

    public userJoinRoom() {
        HlszVO.getVo().initUserInof();
        //状态改变完毕后从所有玩家中找自己是否已入座，若自己入座，则找是否跟自己同桌的用户，将其显示到桌子对面
        let user = HlszVO.getVo().userInfo[GameVO.getVo().dwUserID]
        if (user) {
            HlszVO.getVo().wTableId_2 = user.wTableID;
            HlszVO.getVo().wChairId_2 = user.wChairID;
            HlszVO.getVo().status_2 = user.cbUserStatus;
            HlszVO.getVo().lUserScore = user.lScore;
        }
        //我入座找对手
        if (HlszVO.getVo().wTableId_2 != null && HlszVO.getVo().wTableId_2 != 65535) {
            HlszVO.getVo().wTableId_up = HlszVO.getVo().wTableId_2;
            //根据我所在椅子确定其他玩家在桌面坐哪个位置
            let user3 = (HlszVO.getVo().wChairId_2 + 1) % 5
            let user4 = (HlszVO.getVo().wChairId_2 + 2) % 5
            let user0 = (HlszVO.getVo().wChairId_2 + 3) % 5
            let user1 = (HlszVO.getVo().wChairId_2 + 4) % 5
            for (let i in HlszVO.getVo().userInfo) {
                let user = HlszVO.getVo().userInfo[i]
                if (user.wTableID == HlszVO.getVo().wTableId_2 &&
                    user.dwUserID != GameVO.getVo().dwUserID) {//跟我坐一桌的就是对手
                    if (user.wChairID == user3) {
                        HlszVO.getVo().wTableId_3 = user.wTableID;
                        HlszVO.getVo().wChairId_3 = user.wChairID;
                        HlszVO.getVo().userId_3 = user.dwUserID
                        HlszVO.getVo().userImg_3 = user.wFaceID
                        HlszVO.getVo().userName_3 = user.nickName
                        HlszVO.getVo().userMoney_3 = user.lScore;
                        HlszVO.getVo().status_3 = user.cbUserStatus
                    }
                    if (user.wChairID == user4) {
                        HlszVO.getVo().wTableId_4 = user.wTableID;
                        HlszVO.getVo().wChairId_4 = user.wChairID;
                        HlszVO.getVo().userId_4 = user.dwUserID
                        HlszVO.getVo().userImg_4 = user.wFaceID
                        HlszVO.getVo().userName_4 = user.nickName
                        HlszVO.getVo().userMoney_4 = user.lScore;
                        HlszVO.getVo().status_4 = user.cbUserStatus
                    }
                    if (user.wChairID == user0) {
                        HlszVO.getVo().wTableId_0 = user.wTableID;
                        HlszVO.getVo().wChairId_0 = user.wChairID;
                        HlszVO.getVo().userId_0 = user.dwUserID
                        HlszVO.getVo().userImg_0 = user.wFaceID
                        HlszVO.getVo().userName_0 = user.nickName;
                        HlszVO.getVo().userMoney_0 = user.lScore;
                        HlszVO.getVo().status_0 = user.cbUserStatus
                    }
                    if (user.wChairID == user1) {
                        HlszVO.getVo().wTableId_1 = user.wTableID;
                        HlszVO.getVo().wChairId_1 = user.wChairID;
                        HlszVO.getVo().userId_1 = user.dwUserID;
                        HlszVO.getVo().userImg_1 = user.wFaceID;
                        HlszVO.getVo().userName_1 = user.nickName
                        HlszVO.getVo().userMoney_1 = user.lScore;
                        HlszVO.getVo().status_1 = user.cbUserStatus
                    }
                }
            }
            game.AppFacade.instance.sendNotification(PanelNotify.HLSZ.JOIN_ROOM);
        } else {
            //判断是离开还是换桌。点击换桌后后端踢我不关闭当前游戏页面,等待被移入新房间后再重置此变量
            if (!HlszVO.getVo().huanzhuoClick) {
                if (HlszVO.getVo().wTableId_up != null && HlszVO.getVo().wTableId_2 == 65535) {
                    //上次有座位此次没座位说明被踢了
                    SocketManager.closeSocket(InstructionsEnum.GAME_TYPE_NAME.HLSZ);
                }
            }
        }
    }
    //200-100游戏开始
    public StartGame(data: Object) {
        HlszVO.getVo().initGameInfo();
        let wBankerUser = data["wBankerUser"];   //庄家信息
        let wCurrentUser = data["wCurrentUser"]  //当前玩家
        let lMaxScore = data["lMaxScore"]        //最大下注
        let lCellScore = data["lCellScore"]      //单元下注
        let lCurrentTimes = data["lCurrentTimes"]     //当前倍数
        let lUserMaxScore = data["lUserMaxScore"]     //分数上限
        let cbPlayStatus = data["cbPlayStatus"]      //用户状态
        HlszVO.getVo().wBankerUser = wBankerUser;
        HlszVO.getVo().wCurrentUser = wCurrentUser;
        HlszVO.getVo().lMaxScore = lMaxScore;
        HlszVO.getVo().lCellScore = lCellScore;
        HlszVO.getVo().lCurrentTimes = lCurrentTimes;
        HlszVO.getVo().lUserMaxScore = lUserMaxScore;
        HlszVO.getVo().cbPlayStatus = cbPlayStatus;
        HlszVO.getVo().xiazhuNum_ALL = 0;
        HlszVO.getVo().wTurnCount = 1;
        HlszVO.getVo().wOutCardUser = null;
        //发牌的时候后端会直接扣除所有玩家底注，但不会推送，前端根据lCellScore单注和人数计算总下注数，所有玩家的当前下注就等于底注
        if (Global.isNotEmpty(HlszVO.getVo().userId_0)) {
            HlszVO.getVo().xiaZhuNum_0 = lCellScore
            HlszVO.getVo().xiazhuNum_ALL += lCellScore
            HlszVO.getVo().userMoney_0 -= lCellScore;
            HlszVO.getVo().chess_state_0 = 1
            let user = HlszVO.getVo().userInfo[HlszVO.getVo().userId_0];
            if (user) {
                user.lScore = HlszVO.getVo().userMoney_0
            }
            HlszVO.getVo().shuoHuaMap[HlszVO.getVo().wChairId_0] = false
        }
        if (Global.isNotEmpty(HlszVO.getVo().userId_1)) {
            HlszVO.getVo().xiaZhuNum_1 = lCellScore
            HlszVO.getVo().xiazhuNum_ALL += lCellScore
            HlszVO.getVo().userMoney_1 -= lCellScore;
            HlszVO.getVo().chess_state_1 = 1
            let user = HlszVO.getVo().userInfo[HlszVO.getVo().userId_1];
            if (user) {
                user.lScore = HlszVO.getVo().userMoney_1
            }
            HlszVO.getVo().shuoHuaMap[HlszVO.getVo().wChairId_1] = false
        }
        if (Global.isNotEmpty(GameVO.getVo().dwUserID)) {
            HlszVO.getVo().xiaZhuNum_2 = lCellScore;
            HlszVO.getVo().xiazhuNum_ALL += lCellScore;
            HlszVO.getVo().lUserScore -= lCellScore;
            HlszVO.getVo().chess_state_2 = 1
            let user = HlszVO.getVo().userInfo[GameVO.getVo().dwUserID];
            if (user) {
                user.lScore = HlszVO.getVo().lUserScore;
            }
            HlszVO.getVo().shuoHuaMap[HlszVO.getVo().wChairId_2] = false
        }
        if (Global.isNotEmpty(HlszVO.getVo().userId_3)) {
            HlszVO.getVo().xiaZhuNum_3 = lCellScore
            HlszVO.getVo().xiazhuNum_ALL += lCellScore
            HlszVO.getVo().userMoney_3 -= lCellScore;
            HlszVO.getVo().chess_state_3 = 1
            let user = HlszVO.getVo().userInfo[HlszVO.getVo().userId_3];
            if (user) {
                user.lScore = HlszVO.getVo().userMoney_3
            }
            HlszVO.getVo().shuoHuaMap[HlszVO.getVo().wChairId_3] = false
        }
        if (Global.isNotEmpty(HlszVO.getVo().userId_4)) {
            HlszVO.getVo().xiaZhuNum_4 = lCellScore
            HlszVO.getVo().xiazhuNum_ALL += lCellScore
            HlszVO.getVo().userMoney_4 -= lCellScore;
            HlszVO.getVo().chess_state_4 = 1
            let user = HlszVO.getVo().userInfo[HlszVO.getVo().userId_4];
            if (user) {
                user.lScore = HlszVO.getVo().userMoney_4
            }
            HlszVO.getVo().shuoHuaMap[HlszVO.getVo().wChairId_4] = false
        }
        HlszVO.getVo().xiazhuNum = lCellScore;
        game.AppFacade.instance.sendNotification(PanelNotify.HLSZ.START_GAME);
    }
    //200-101下注
    public XiaZhu(data: Object) {
        let wCurrentUser = data["wCurrentUser"]//当前用户
        let wAddScoreUser = data["wAddScoreUser"]//加注用户
        let lAddScoreCount = data["lAddScoreCount"];//加注数目
        let lCurrentTimes = data["lCurrentTimes"]//当前倍数
        let wCompareState = data["wCompareState"]//是否比牌
        //每个玩家说话过后统计一次总下注次数，次数达到总人数时为一圈
        if (lAddScoreCount != 0) {
            HlszVO.getVo().shuoHuaMap[wAddScoreUser] = true
            this.findLunshu()
        }
        HlszVO.getVo().wCurrentUser = wCurrentUser;
        HlszVO.getVo().wOutCardUser = wAddScoreUser;
        HlszVO.getVo().lCurrentTimes = lCurrentTimes;
        HlszVO.getVo().xiazhuNum_ALL += lAddScoreCount;
        if (HlszVO.getVo().wChairId_0 == wAddScoreUser) {
            HlszVO.getVo().xiaZhuNum_0 += lAddScoreCount;
            HlszVO.getVo().userMoney_0 -= lAddScoreCount;
            HlszVO.getVo().xiaZhuUser = 0;
            let user = HlszVO.getVo().userInfo[HlszVO.getVo().userId_0];
            if (user) {
                user.lScore = HlszVO.getVo().userMoney_0
            }
        }
        if (HlszVO.getVo().wChairId_1 == wAddScoreUser) {
            HlszVO.getVo().xiaZhuNum_1 += lAddScoreCount;
            HlszVO.getVo().userMoney_1 -= lAddScoreCount;
            HlszVO.getVo().xiaZhuUser = 1;
            let user = HlszVO.getVo().userInfo[HlszVO.getVo().userId_1];
            if (user) {
                user.lScore = HlszVO.getVo().userMoney_1
            }
        }
        if (HlszVO.getVo().wChairId_2 == wAddScoreUser) {
            HlszVO.getVo().xiaZhuNum_2 += lAddScoreCount;
            HlszVO.getVo().lUserScore -= lAddScoreCount;
            HlszVO.getVo().xiaZhuUser = 2;
            let user = HlszVO.getVo().userInfo[GameVO.getVo().dwUserID];
            if (user) {
                user.lScore = HlszVO.getVo().lUserScore;
            }
        }
        if (HlszVO.getVo().wChairId_3 == wAddScoreUser) {
            HlszVO.getVo().xiaZhuNum_3 += lAddScoreCount;
            HlszVO.getVo().userMoney_3 -= lAddScoreCount;
            HlszVO.getVo().xiaZhuUser = 3;
            let user = HlszVO.getVo().userInfo[HlszVO.getVo().userId_3];
            if (user) {
                user.lScore = HlszVO.getVo().userMoney_3
            }
        }
        if (HlszVO.getVo().wChairId_4 == wAddScoreUser) {
            HlszVO.getVo().xiaZhuNum_4 += lAddScoreCount;
            HlszVO.getVo().userMoney_4 -= lAddScoreCount;
            HlszVO.getVo().xiaZhuUser = 4;
            let user = HlszVO.getVo().userInfo[HlszVO.getVo().userId_4];
            if (user) {
                user.lScore = HlszVO.getVo().userMoney_4
            }
        }
        if (HlszVO.getVo().xiazhuNum == 0) {//发牌时前端已自动下底注，因此这里永远不会进来
            HlszVO.getVo().xiazhuType = 0;
        } else if (lAddScoreCount == HlszVO.getVo().xiazhuNum) {
            HlszVO.getVo().xiazhuType = 1;
        } else if (lAddScoreCount > HlszVO.getVo().xiazhuNum) {
            HlszVO.getVo().xiazhuType = 2;
        }
        if (wCompareState == 1) {
            HlszVO.getVo().xiazhuType = 3;
        }
        HlszVO.getVo().xiazhuNum = lAddScoreCount;
        game.AppFacade.instance.sendNotification(PanelNotify.HLSZ.GEN_ZHU);
        if (wCompareState == 1 && HlszVO.getVo().wChairId_2 == wCurrentUser) {
            //比牌下注 或者 强制开牌下注
            if (HlszVO.getVo().qiangzhibipai) {
                if (HlszVO.getVo().qiangzhibipai_userArr.length != 0) {
                    var obj = {
                        wCompareUser: HlszVO.getVo().qiangzhibipai_userArr[0]
                    }
                    SocketManager.sendMessage(InstructionsEnum.GAME_TYPE_NAME.HLSZ, RegDataHlsz.CMD_GP_OpenCard, obj);
                }
            } else {
                let obj = {
                    wCompareUser: HlszVO.getVo().mySelectUser
                }
                SocketManager.sendMessage(InstructionsEnum.GAME_TYPE_NAME.HLSZ, RegDataHlsz.CMD_GP_CompareCard, obj);
            }
        }
    }
    //200-102弃牌
    public QiPai(data: Object) {
        let wGiveUpUser = data["wGiveUpUser"];
        //每个玩家说话过后统计一次总下注次数，次数达到总人数时为一圈
        delete HlszVO.getVo().shuoHuaMap[wGiveUpUser]
        this.findLunshu()
        HlszVO.getVo().wOutCardUser = wGiveUpUser;
        if (wGiveUpUser == HlszVO.getVo().wChairId_0) {
            HlszVO.getVo().chess_state_0 = 3;
            HlszVO.getVo().qiPaiUser = 0;
        }
        if (wGiveUpUser == HlszVO.getVo().wChairId_1) {
            HlszVO.getVo().chess_state_1 = 3;
            HlszVO.getVo().qiPaiUser = 1;
        }
        if (wGiveUpUser == HlszVO.getVo().wChairId_2) {
            HlszVO.getVo().chess_state_2 = 3;
            HlszVO.getVo().qiPaiUser = 2;
            HlszVO.getVo().qiangzhibipai = false
            HlszVO.getVo().qiangzhibipai_userArr = []
        }
        if (wGiveUpUser == HlszVO.getVo().wChairId_3) {
            HlszVO.getVo().chess_state_3 = 3;
            HlszVO.getVo().qiPaiUser = 3
        }
        if (wGiveUpUser == HlszVO.getVo().wChairId_4) {
            HlszVO.getVo().chess_state_4 = 3;
            HlszVO.getVo().qiPaiUser = 4
        }
        game.AppFacade.instance.sendNotification(PanelNotify.HLSZ.QI_PAI);
    }

    //200-106看牌
    public KanPai(data: Object) {
        let wLookCardUser = data["wLookCardUser"];
        let cbCardData: Array<any> = data["cbCardData"];
        HlszVO.getVo().wOutCardUser = wLookCardUser;
        HlszVO.getVo().cbCardDataALL[wLookCardUser] = cbCardData;
        if (wLookCardUser == HlszVO.getVo().wChairId_0) {
            HlszVO.getVo().chess_state_0 = 2;
            HlszVO.getVo().kanPaiser = 0;
        }
        if (wLookCardUser == HlszVO.getVo().wChairId_1) {
            HlszVO.getVo().chess_state_1 = 2;
            HlszVO.getVo().kanPaiser = 1;
        }
        if (wLookCardUser == HlszVO.getVo().wChairId_2) {
            HlszVO.getVo().chess_state_2 = 2;
            HlszVO.getVo().kanPaiser = 2;
            HlszVO.getVo().cbCardType_my = data["cbCardType"];
        }
        if (wLookCardUser == HlszVO.getVo().wChairId_3) {
            HlszVO.getVo().chess_state_3 = 2;
            HlszVO.getVo().kanPaiser = 3;
        }
        if (wLookCardUser == HlszVO.getVo().wChairId_4) {
            HlszVO.getVo().chess_state_4 = 2;
            HlszVO.getVo().kanPaiser = 4;
        }
        game.AppFacade.instance.sendNotification(PanelNotify.HLSZ.KAN_PAI);
    }
    //比牌200-105
    public BiPai(data: Object) {
        let wCurrentUser = data["wCurrentUser"]//当前用户
        let wCompareUser: Array<number> = data["wCompareUser"]//比牌的两个用户
        let wLostUser = data["wLostUser"]//输牌的用户
        delete HlszVO.getVo().shuoHuaMap[wLostUser]

        HlszVO.getVo().wCurrentUser = wCurrentUser;
        if (wLostUser == HlszVO.getVo().wChairId_0) {
            HlszVO.getVo().shupaiUser = 0;
            HlszVO.getVo().chess_state_0 = 4;
        }
        if (wLostUser == HlszVO.getVo().wChairId_1) {
            HlszVO.getVo().shupaiUser = 1
            HlszVO.getVo().chess_state_1 = 4;
        }
        if (wLostUser == HlszVO.getVo().wChairId_2) {
            HlszVO.getVo().shupaiUser = 2
            HlszVO.getVo().chess_state_2 = 4;
            HlszVO.getVo().qiangzhibipai = false
            HlszVO.getVo().qiangzhibipai_userArr = []
        }
        if (wLostUser == HlszVO.getVo().wChairId_3) {
            HlszVO.getVo().shupaiUser = 3
            HlszVO.getVo().chess_state_3 = 4;
        }
        if (wLostUser == HlszVO.getVo().wChairId_4) {
            HlszVO.getVo().shupaiUser = 4
            HlszVO.getVo().chess_state_4 = 4;
        }

        if (wCompareUser[0] == HlszVO.getVo().wChairId_0) {
            HlszVO.getVo().biPaiUser = 0;
        }
        if (wCompareUser[0] == HlszVO.getVo().wChairId_1) {
            HlszVO.getVo().biPaiUser = 1
        }
        if (wCompareUser[0] == HlszVO.getVo().wChairId_2) {
            HlszVO.getVo().biPaiUser = 2
            HlszVO.getVo().PkMeUser.push(wCompareUser[1])//跟我比牌的人纪录下来翻他的牌
        }
        if (wCompareUser[0] == HlszVO.getVo().wChairId_3) {
            HlszVO.getVo().biPaiUser = 3
        }
        if (wCompareUser[0] == HlszVO.getVo().wChairId_4) {
            HlszVO.getVo().biPaiUser = 4
        }

        if (wCompareUser[1] == HlszVO.getVo().wChairId_0) {
            HlszVO.getVo().biPaiUser2 = 0;
        }
        if (wCompareUser[1] == HlszVO.getVo().wChairId_1) {
            HlszVO.getVo().biPaiUser2 = 1
        }
        if (wCompareUser[1] == HlszVO.getVo().wChairId_2) {
            HlszVO.getVo().biPaiUser2 = 2
            HlszVO.getVo().PkMeUser.push(wCompareUser[0])//跟我比牌的人纪录下来翻他的牌
        }
        if (wCompareUser[1] == HlszVO.getVo().wChairId_3) {
            HlszVO.getVo().biPaiUser2 = 3
        }
        if (wCompareUser[1] == HlszVO.getVo().wChairId_4) {
            HlszVO.getVo().biPaiUser2 = 4
        }
        // if (HlszVO.getVo().biPaiUser == 3 || HlszVO.getVo().biPaiUser == 4) {//比牌动画时HlszVO.getVo().biPaiUser在左边，如果HlszVO.getVo().biPaiUser 是右边玩家的作为，与biPaiUser2 互换
        //     let num = HlszVO.getVo().biPaiUser;
        //     HlszVO.getVo().biPaiUser = HlszVO.getVo().biPaiUser2;
        //     HlszVO.getVo().biPaiUser2 = num;
        // }
        game.AppFacade.instance.sendNotification(PanelNotify.HLSZ.BI_PAI);
    }
    //200-104 结算
    public gameOver(data: Object) {
        HlszVO.getVo().qiangzhibipai = false
        HlszVO.getVo().qiangzhibipai_userArr = []
        HlszVO.getVo().chess_state_2 = 0;
        let lGameTax = data["lGameTax"]					                	//游戏税收
        let wEndState = data["wEndState"]							        //结束状态
        let bDelayOverGame = data["bDelayOverGame"]			                 //延迟开始    
        let wServerType = data["wServerType"]			                    //房间类型
        let cbCardData: Array<Array<number>> = data["cbCardData"]			//用户扑克
        let cbCardType: Array<number> = data["cbCardType"]					//用户牌型
        let lGameScore: Array<number> = data["lGameScore"]					//游戏得分
        HlszVO.getVo().wCurrentUser = null;
        HlszVO.getVo().cbCardDataALL = cbCardData;
        HlszVO.getVo().cbCardType = cbCardType;
        HlszVO.getVo().lGameScore = lGameScore;
        //找出得分最高的赢家
        for (let i = 0; i < lGameScore.length; i++) {
            if (lGameScore[i] > 0) {
                HlszVO.getVo().winUser = i;
                break;
            }
        }
        game.AppFacade.instance.sendNotification(PanelNotify.HLSZ.GAME_OVER);
    }
    //100-101 中途加入
    dataRecovery(data: Object) {
        if (RegDataHlsz.MainCMD_MsgId[100][101] == RegDataHlsz.gameStart) {
            HlszVO.getVo().initGameInfo();
            // HlszVO.getVo().xiazhuNum_ALL = 0;
            // HlszVO.getVo().wOutCardUser = null;
            let lCurrentTimes = data["lCurrentTimes"]//当前倍数  
            let lMaxCellScore = data["lMaxCellScore"]//单元上限
            let lCellScore = data["lCellScore"]//单元下注
            let wBankerUser = data["wBankerUser"] //庄家用户
            let wCurrentUser = data["wCurrentUser"]  //当前玩家
            let cbHandCardData: Array<number> = data["cbHandCardData"]//扑克数据
            let lTableScore: Array<number> = data["lTableScore"]; //下注数目 

            let bCompareState: Array<number> = data["bCompareState"]//比牌状态 
            let bMingZhu: Array<boolean> = data["bMingZhu"]//用户看牌状态
            let cbPlayStatus: Array<any> = data["cbPlayStatus"]//玩家游戏状态  
            let lUserMaxScore = data["lUserMaxScore"]//用户分数上限
            let cbTurns = data["cbTurns"];//当前轮数
            HlszVO.getVo().wTurnCount = cbTurns;
            HlszVO.getVo().lCurrentTimes = lCurrentTimes;
            HlszVO.getVo().lMaxScore = lMaxCellScore;
            HlszVO.getVo().lCellScore = lCellScore;
            HlszVO.getVo().wBankerUser = wBankerUser;
            HlszVO.getVo().wCurrentUser = wCurrentUser;
            for (let i in lTableScore) {
                HlszVO.getVo().xiazhuNum_ALL += lTableScore[i];
            }
            //恢复用户手牌状态和金币//自己中途加入不可能有自己的牌
            //手牌状态先看是否闷牌和看牌，然后看是否弃牌或已输牌(后端只给了游戏状态0:1 无法确定是弃牌还是输牌，所以状态为0时随机取弃牌或输牌)
            if (Global.isNotEmpty(HlszVO.getVo().wChairId_0)) {
                HlszVO.getVo().xiaZhuNum_0 = lTableScore[HlszVO.getVo().wChairId_0]
                if (bMingZhu[HlszVO.getVo().wChairId_0] == true) {
                    HlszVO.getVo().chess_state_0 = 2
                }
                if (cbPlayStatus[HlszVO.getVo().wChairId_0] == 0) {
                    HlszVO.getVo().chess_state_0 = Math.random() < 0.5 ? 3 : 4;
                } else {
                    HlszVO.getVo().shuoHuaMap[HlszVO.getVo().wChairId_0] = false
                }
            }
            if (Global.isNotEmpty(HlszVO.getVo().wChairId_1)) {
                HlszVO.getVo().xiaZhuNum_1 = lTableScore[HlszVO.getVo().wChairId_1]
                if (bMingZhu[HlszVO.getVo().wChairId_1] == true) {
                    HlszVO.getVo().chess_state_1 = 2
                }
                if (cbPlayStatus[HlszVO.getVo().wChairId_1] == 0) {
                    HlszVO.getVo().chess_state_1 = Math.random() < 0.5 ? 3 : 4;
                } else {
                    HlszVO.getVo().shuoHuaMap[HlszVO.getVo().wChairId_1] = false
                }
            }
            if (Global.isNotEmpty(HlszVO.getVo().wChairId_3)) {
                HlszVO.getVo().xiaZhuNum_3 = lTableScore[HlszVO.getVo().wChairId_3]
                if (bMingZhu[HlszVO.getVo().wChairId_3] == true) {
                    HlszVO.getVo().chess_state_3 = 2
                }
                if (cbPlayStatus[HlszVO.getVo().wChairId_3] == 0) {
                    HlszVO.getVo().chess_state_3 = Math.random() < 0.5 ? 3 : 4;
                } else {
                    HlszVO.getVo().shuoHuaMap[HlszVO.getVo().wChairId_3] = false
                }
            }
            if (Global.isNotEmpty(HlszVO.getVo().wChairId_4)) {
                HlszVO.getVo().xiaZhuNum_4 = lTableScore[HlszVO.getVo().wChairId_4]
                if (bMingZhu[HlszVO.getVo().wChairId_4] == true) {
                    HlszVO.getVo().chess_state_4 = 2
                }
                if (cbPlayStatus[HlszVO.getVo().wChairId_4] == 0) {
                    HlszVO.getVo().chess_state_4 = Math.random() < 0.5 ? 3 : 4;
                } else {
                    HlszVO.getVo().shuoHuaMap[HlszVO.getVo().wChairId_4] = false
                }
            }
            if (lTableScore[HlszVO.getVo().wChairId_2] != 0) {//自己有下注说明自己回到了之前的房间，需要恢复自己的手牌
                HlszVO.getVo().xiaZhuNum_2 = lTableScore[HlszVO.getVo().wChairId_2]
                if (bMingZhu[HlszVO.getVo().wChairId_2] == true) {
                    HlszVO.getVo().chess_state_2 = 2
                }
                if (cbPlayStatus[HlszVO.getVo().wChairId_2] == 0) {
                    HlszVO.getVo().chess_state_4 = Math.random() < 0.5 ? 3 : 4;
                } else {
                    HlszVO.getVo().shuoHuaMap[HlszVO.getVo().wChairId_2] = false
                }
            }
            //从庄家到当前玩家这一段内玩家已经说过话，当前玩家以后的人没说话，计算轮数要用
            var user = HlszVO.getVo().wCurrentUser - 1
            if (user < 0) {
                user = 4
            }
            while (user != HlszVO.getVo().wBankerUser) {
                if (HlszVO.getVo().shuoHuaMap[user] != undefined) {
                    HlszVO.getVo().shuoHuaMap[user] = true
                }
                user--;
                if (user < 0) {
                    user = 4
                }
            }
            game.AppFacade.instance.sendNotification(PanelNotify.HLSZ.DATA_RECOVERY);
        }
        // if (RegDataHlsz.MainCMD_MsgId[100][101] == RegDataHlsz.free) {
        //     let lCellScore = data["lCellScore"]//单元下注
        //     HlszVO.getVo().lCellScore = lCellScore;
        // }
    }

    //获取牌局编号
    public getSerialNumber(data: Object) {
        HlszVO.getVo().gameNumbering = data["szSerialNumber"];
        game.AppFacade.instance.sendNotification(PanelNotify.HLSZ.GET_SERIAL_NUMBER)
    }
    //获取游戏状态8-100
    public getGameStatus(data: Object) {
        HlszVO.getVo().cbGameStatus = data["cbGameStatus"];
    }

    private findLunshu() {
        //查找map只要有一个活人为false说明当前轮数没有结束，死人已移除
        for (var i in HlszVO.getVo().shuoHuaMap) {
            if (HlszVO.getVo().shuoHuaMap[i] == false) {
                return;
            }
        }
        //存活的人都为true 说明进入下一轮，重置所有人状态为false
        HlszVO.getVo().wTurnCount++;
        for (var i in HlszVO.getVo().shuoHuaMap) {
            HlszVO.getVo().shuoHuaMap[i] = false
        }
    }
}

